package com.caac.core.dm;

import java.util.Date;

import com.caac.core.config.ActionConf;

/**
 * <p>
 * Title:
 * </p>
 * <p>
 * Description:
 * </p>
 * <p>
 * Copyright: Copyright caac 2006
 * </p>
 * <p>
 * Company: caac
 * </p>
 * 
 * @author <a href="mailto:project@caac.com.cn">Project Group</a>
 * @version 1.0
 */

public abstract class User extends BaseDm {
	private String id;

	private String username;

	private String password;

	private String realName;

	private String phone;

	private String fax;

	private String mobile;

	private String email;

	private String deptCode;

	private String deptName;

	private String duty;

	private String subClass;

	private String state;

	private String notes;

	private Integer loginNum;

	private Date createTime;

	private String creator;

	private Date updateTime;

	private String updator;

	private String isDel;

	public String getCreator() {
		return creator;
	}

	public void setCreator(String creator) {
		this.creator = creator;
	}

	public String getDeptCode() {
		return deptCode;
	}

	public void setDeptCode(String deptCode) {
		this.deptCode = deptCode;
	}

	public String getDeptName() {
		return deptName;
	}

	public void setDeptName(String deptName) {
		this.deptName = deptName;
	}

	public String getDuty() {
		return duty;
	}

	public void setDuty(String duty) {
		this.duty = duty;
	}

	public String getFax() {
		return fax;
	}

	public void setFax(String fax) {
		this.fax = fax;
	}

	public String getIsDel() {
		return isDel;
	}

	public void setIsDel(String isDel) {
		this.isDel = isDel;
	}

	public Integer getLoginNum() {
		return loginNum;
	}

	public void setLoginNum(Integer loginNum) {
		this.loginNum = loginNum;
	}

	public String getNotes() {
		return notes;
	}

	public void setNotes(String notes) {
		this.notes = notes;
	}

	public String getSubClass() {
		return subClass;
	}

	public void setSubClass(String subClass) {
		this.subClass = subClass;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	public String getUpdator() {
		return updator;
	}

	public void setUpdator(String updator) {
		this.updator = updator;
	}

	public String getId() {
		return this.id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getRealName() {
		return realName;
	}

	public void setRealName(String realName) {
		this.realName = realName;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getState() {
		return state;
	}

	public String getEmail() {
		return email;
	}

	public String getMobile() {

		return mobile;
	}

	public String getPhone() {
		return phone;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setState(String state) {
		this.state = state;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	protected int doHashCode() {
		return getHashCodeBuilder().append(username).toHashCode();
	}

	protected boolean doEquals(Object object) {
		User other = (User) object;
		return getEqualsBuilder().append(username, other.username).isEquals();
	}

	public boolean isValidPassword(String password) {
		return this.password.equals(password);
	}

	public boolean isAuthorized(ActionConf actionConf) {
		if (!isInDomain(actionConf)) {
			return false;
		}
		return isAccessible(actionConf);
	}

	private boolean isInDomain(ActionConf actionConf) {
		return true;
	}

	protected abstract boolean isAccessible(ActionConf actionConf);

}
